/*
 *代码由框架生成,任何更改都可能导致被代码生成器覆盖
 *如果要增加方法请在当前目录下Partial文件夹EquipmentController编写
 */
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Autofac.Core;
using Microsoft.AspNetCore.Mvc;
using VOL.Core.BaseProvider;
using VOL.Core.Controllers.Basic;
using VOL.Core.Utilities;
using VOL.Entity.AttributeManager;
using VOL.Entity.DomainModels;
using VOL.Entity.DomainModels.EquipmentManage;
using VOL.Entity.DomainModels.WorkforceManage;
using VOL.SmartMecial.Dtos;
using VOL.SmartMecial.IServices;
using VOL.SmartMecial.IServices.EquipmentManage;
using VOL.SmartMecial.IServices.NurseManage;
using VOL.SmartMecial.IServices.WorkforceManage;
using VOL.SmartMecial.Services.EquipmentManage;
using VOL.SmartMecial.Services.NurseManage;
namespace VOL.SmartMecial.Controllers.SmartMecial
{
    [Route("api/EquipmentController")]
    [PermissionTable(Name = "EquipmentController")]
    public class EquipmentRecordController : ControllerBase
    {
        private readonly IEquipmentRecordService _equipmentRecordService;
        private readonly IPatientServices _patientService;
        private readonly IWardAreaService _wardAreaService;

        public EquipmentRecordController(IEquipmentRecordService equipmentRecordService, IPatientServices patientService,IWardAreaService wardAreaService)
        {
            this._equipmentRecordService = equipmentRecordService;
            this._patientService = patientService;
            this._wardAreaService = wardAreaService;
        }

        /// <summary>
        /// 设备借还分页显示
        /// </summary>
        /// <param name="equipmentRecordDTO">查询条件</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">条数</param>
        /// <returns>返回</returns>
        [HttpGet("GetEquipmentRecord")]
        public Task<WebResponseContent> GetEquipmentRecord(EquipmentRecordDTO equipmentRecordDTO, int pageIndex, int pageSize)
        {
            return _equipmentRecordService.GetEquipmentRecord(equipmentRecordDTO, pageIndex, pageSize);
        }

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="record">实体</param>
        /// <returns>返回</returns>
        [HttpPost("AddEquipmentRecord")]
        public async Task<int> AddEquipmentRecord([FromBody]EquipmentRecord record)
        {
            return await _equipmentRecordService.Add(record);
        }

        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="record">实体</param>
        /// <returns>返回</returns>
        [HttpPost("UpdEquipmentRecord")]
        public async Task<int> UpdEquipmentRecord([FromBody]EquipmentRecord record)
        {
            return await _equipmentRecordService.Update(record);
        }

        /// <summary>
        /// 同一个设备类型的设备编号不能被重复借出。
        /// </summary>
        /// <param name="equipmentNo">设备编号</param>
        /// <param name="equipmentType">设备类型</param>
        /// <returns>返回</returns>
        [HttpGet("CheckEquipmentStatus")]
        public async Task<WebResponseContent> CheckEquipmentStatus(string equipmentNo, string equipmentType)
        {
            return await _equipmentRecordService.CheckEquipmentStatus(equipmentNo, equipmentType);
        }

        /// <summary>
        /// 患者床位列表
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">条数</param>
        /// <returns>返回</returns>
        [HttpGet("GetPatient")]
        public  Task<WebResponseContent> GetPatient(int pageIndex, int pageSize)
        {
            return _patientService.GetPatient(pageIndex, pageSize);
        }

        /// <summary>
        /// 回显患者信息
        /// </summary>
        /// <param name="patientCode">患者编号</param>
        /// <returns>返回</returns>
        [HttpGet("GetPatientDetail")]
        public async Task<WebResponseContent> GetPatientDetail(string patientCode)
        {
            return await _patientService.GetPatientDetail(patientCode);
        }

        /// <summary>
        /// 病区下拉框
        /// </summary>
        /// <returns>返回</returns>
        [HttpGet("GetWardArea")]
        public async Task<WebResponseContent> GetWardArea()
        {
            return await _wardAreaService.GetWardArea();
        }

        /// <summary>
        /// 根据病区id查询病房及床位信息
        /// </summary>
        /// <param name="wardAreaId">病区ID</param>
        /// <returns>病房和床位的树形结构数据</returns>
        [HttpGet("GetWardAreaBeds")]
        public async Task<APIResult<List<WardBedWardAreaDto>>> GetWardAreaBeds(int wardAreaId)
        {
            return await _wardAreaService.GetWardAreaBeds(wardAreaId);
        }
        /// <summary>
        /// 分配床位
        /// </summary>
       
        [HttpPost("UpdPatient")]
        public async Task<int> UpdPatient([FromBody]Patient patient)
        {
            return await _wardAreaService.UpdPatient(patient);
        }

        /// <summary>
        /// 人员分组
        /// </summary>
        /// <returns></returns>
        [HttpGet("ShowNurseGroup")]
        public async Task<WebResponseContent> ShowNurseGroup()
        {
            return await _patientService.ShowNurseGroup();
        }

        /// <summary>
        /// 人员分组的添加
        /// </summary>
        /// <returns></returns>
        [HttpPost("AddNurseGroup")]
        public async Task<int> AddNurseGroup([FromBody]NurseGroupModel nurseGroup)
        {
            return await _patientService.AddNurseGroup(nurseGroup);
        }

        /// <summary>
        /// 人员分组的编辑
        /// </summary>
        /// <returns></returns>
        [HttpPost("UpdNurseGroup")]
        public async Task<int> UpdNurseGroup([FromBody] NurseGroupModel nurseGroup)
        {
            return await _patientService.UpdNurseGroup(nurseGroup);
        }

        /// <summary>
        /// 人员分组的移除
        /// </summary>
        /// <returns></returns>
        [HttpPost("DelNurseGroup")]
        public async Task<int> DelNurseGroup(int id)
        {
            return await _patientService.DelNurseGroup(id);
        }
    }
}

